// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // »Project« Talina Gaming System (TgS) (∂) // »File« TgS Common - Base - Type [File].h // »Author« Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com) // »Version« 4.0 // ------------------------------------------------------------------------------------------------------------------------------ // // Copyright: © 2002-2010, Andrew Aye. All Rights Reserved. // This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. // Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following // disclaimers in the documentation and other materials provided with the distribution. // Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // The intellectual property rights of the algorithms used reside with Andrew Aye. You may not use this software, in whole or // in part, in support of any commercial product without the express written consent of the author. // There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_COMMON_BASE_TYPE_FILE_H_) #define _TGS_COMMON_BASE_TYPE_FILE_H_ #pragma once // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Constants // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // enum { KTgMAX_NUM_FILE = 512 }; enum { KTgMAX_FILE_PATH = 240 }; enum { KTgMAX_FILE_NAME = 32 }; enum ETgFILE_PLATFORM { ETgFILE_PLATFORM_W32 = 1<<0, ETgFILE_PLATFORM_W64 = 1<<1, ETgFILE_PLATFORM_XB2 = 1<<2, ETgFILE_PLATFORM_PS3 = 1<<3, ETgFILE_PLATFORM_IPHONE = 1<<4, ETgFILE_PLATFORM_IPAD = 1<<5 }; enum ETgFILE_FLAG { ETgFILE_FLAG_ENDIAN = 1<<0 }; // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Type Definitions // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Describes the type and location of a data section in the file TgTYPE_DECLARE( struct STg2_File_Section, STg2_File_Section ); struct STg2_File_Section { TgUINT32 m_uiFourCC; //« Descriptor of the file section TgUINT32 m_uiOffset; //« Offset in file, from file header, to the data header. }; // The file block marks the beginning of a block uniquely identified by the Kernel File OS. In a traditional IO system // this would be a discrete file on the recorded media. However, because of loading requirements on various hardware // platforms, the mapping of a discrete file block is not guaranteed to map 1:1 to a specific file on the media though it // will always be capable of being uniquely identified and used by the Kernel system. TgTYPE_DECLARE( struct STg2_File_Block, STg2_File_Block ); struct STg2_File_Block { // File Block - This describes the file format definition TgUINT32 m_uiFourCC; //« Must be 'TGSF' TgUINT32 m_uiSize; //« Size of the Header TgUINT16 m_uiVersion; //« Version of the file format TgUINT08 m_uiMachine; //« Machine targeted by file TgUINT08 m_uiFlags; //« Used to describe file or machine traits // Tool Block - This describes the tool used to make the file. TgUINT16 m_uiTool_Version; //« Version of the tool used to make file TgUINT16 m_uiTool_ID; //« Generic Identifier for the tool used to make this file // Section Block - This describes the section listing after the header TgUINT16 m_uiSection_Version; //« Version of the file section entries TgUINT16 m_uiSection_Count; //« Count of the file section entries TgUINT32 m_uiSection_Size; //« Size of the file section entries // Contiguous list of data sections in this file block //STg2_File_Section m_atgSection[]; }; #pragma message("TODO: FIX ZERO SIZE ARRAY") // Describes the subsequent (following) data section TgTYPE_DECLARE( struct STg2_File_Data, STg2_File_Data ); struct STg2_File_Data { TgUINT32 m_uiFourCC; //« Descriptor of the file section TgUINT32 m_uiSize; //« Size of the file section TgUINT16 m_uiVersion; //« Version of the file section TgUINT16 m_uiOffset; //« Offset from this header, to the data. (Allow for data alignment) }; // Describe a data test section (used by the unit test) - 4CC = 'TEST' TgTYPE_DECLARE( struct STg2_File_Data__TEST, STg2_File_Data__TEST ); struct STg2_File_Data__TEST { STg2_File_Data m_tgHeader; TgUINT32 m_uiTest; TgUINT32 m_nuiData; //TgUINT08 m_pData[]; }; #pragma message("TODO: FIX ZERO SIZE ARRAY") // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Public Interface // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // P_TgCHAR tgCM_Path_Add_Seperator( PC_TgCHAR, C_TgUINT32 ); P_TgCHAR tgCM_Path_Add_Extension( PC_TgCHAR, C_TgUINT32, CPC_TgCHAR ); P_TgCHAR tgCM_Path_Copy( PC_TgCHAR, C_TgUINT32, CPC_TgCHAR ); P_TgCHAR tgCM_Path_Append( PC_TgCHAR, C_TgUINT32, CPC_TgCHAR ); P_TgCHAR tgCM_Path_Common_Prefix( PC_TgCHAR, C_TgUINT32, CPC_TgCHAR, CPC_TgCHAR ); P_TgCHAR tgCM_Path_Remove_Seperator( PC_TgCHAR ); P_TgCHAR tgCM_Path_Remove_Extension( PC_TgCHAR ); P_TgCHAR tgCM_Path_Remove_File_Name( PC_TgCHAR ); P_TgCHAR tgCM_Path_Rename_Extension( PC_TgCHAR, C_TgUINT32, CPC_TgCHAR ); P_TgCHAR tgCM_Path_Remove_Directory( PC_TgCHAR ); P_TgCHAR tgCM_Path_Init( PC_TgCHAR, C_TgUINT32, ... ); P_TgCHAR tgCM_Path_Find_Extension( PC_TgCHAR ); P_TgCHAR tgCM_Path_Find_File_Name( PC_TgCHAR ); TgVOID tgCM_Path_Check_File_Block_With_Assert( CPCU_STg2_File_Block ); #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////